<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
    xmlns:s="http://jboss.com/products/seam/taglib"
    xmlns:ui="http://java.sun.com/jsf/facelets"
    xmlns:f="http://java.sun.com/jsf/core"
    xmlns:h="http://java.sun.com/jsf/html"
    xmlns:a="http://richfaces.org/a4j"
    xmlns:rich="http://richfaces.org/rich"
    template="layout/templateInventario.xhtml">

<ui:define name="body">

    <h:form id="invIngreso" styleClass="edit">

        <rich:panel>
            <f:facet name="header">#{invIngresoHome.managed ? 'Editar' : 'Agreagr'}Ingreso</f:facet>


            

			<s:decorate id="ingNumFacturaField" template="layout/edit.xhtml">
                <ui:define name="label">N# Factura:</ui:define>
                <h:inputText id="ingNumFactura"
                          value="#{invIngresoHome.instance.ingNumFactura}"
                          
                          requiredMessage="Ingrese numeros !!!"
                          
                          >
                              <f:convertNumber pattern="######"  />
                    <a:support event="onblur" reRender="ingNumFacturaField" bypassUpdates="true" ajaxSingle="true"/>
                </h:inputText>
            </s:decorate>

<s:decorate id="egrDescuentoField" template="layout/edit.xhtml">
                <ui:define name="label">Cur:</ui:define>
                <h:inputText id="egrDescuento"
                          value="#{invIngresoHome.instance.ingCur}" >
                          <f:convertNumber pattern="######" />
                    <a:support event="onblur" reRender="egrDescuentoField" bypassUpdates="true" ajaxSingle="true"/>
                </h:inputText>
            </s:decorate>
<s:decorate id="IdPerfil" template="layout/edit.xhtml">
     <ui:define name="label">Proveedor:</ui:define>
		<h:selectOneMenu value="#{invIngresoHome.instance.codigoProveedor}"
requiredMessage="Selecciones el proveedor!!!"
required="true" 
	defaultLabel="Seleccione..." 
 				directInputSuggestions="true"
 				enableManualInput="false" 
>
 				
<f:selectItems value="#{grupoListado.listaProveedorSelectItems}"  />
</h:selectOneMenu>
		  </s:decorate>
              <s:decorate id="ingDescuentoField" template="layout/edit.xhtml">
                <ui:define name="label">Descuentos:</ui:define>
                <h:inputText id="ingDescuento"
                          value="#{invIngresoHome.instance.ingDescuento}"
                           size="20">
                    <a:support event="onblur" reRender="ingDescuentoField" bypassUpdates="true" ajaxSingle="true"/>
                </h:inputText>
            </s:decorate>


            <s:decorate id="ingFechaField" template="layout/edit.xhtml">
                <ui:define name="label">Fecha:</ui:define>
                <rich:calendar id="ingFecha"
                          value="#{invIngresoHome.instance.ingFecha}" datePattern="MM/dd/yyyy" />
            </s:decorate>

             <s:decorate id="ingIvaField" template="layout/edit.xhtml">
                <ui:define name="label">Iva:</ui:define>
                <h:inputText id="ingIva"
                          value="#{invIngresoHome.instance.ingIva}"
                           size="20">
                    <a:support event="onblur" reRender="ingIvaField" bypassUpdates="true" ajaxSingle="true"/>
                </h:inputText>
            </s:decorate>


            

            

            <s:decorate id="ingPrecioTotalField" template="layout/edit.xhtml">
                <ui:define name="label">Precio Total:</ui:define>
                <h:inputText id="ingPrecioTotal"
                          value="#{invIngresoHome.instance.ingPrecioTotal}"
                           size="20">
                    <a:support event="onblur" reRender="ingPrecioTotalField" bypassUpdates="true" ajaxSingle="true"/>
                   
                </h:inputText>
            </s:decorate>
            
			<s:decorate id="ingObservacionField" template="layout/edit.xhtml">
                <ui:define name="label">Observaciones:</ui:define>
                <h:inputText id="ingObservacion"
                           size="100"
                      maxlength="100"
                          value="#{invIngresoHome.instance.ingObservacion}">
                    <a:support event="onblur" reRender="ingObservacionField" bypassUpdates="true" ajaxSingle="true"/>
                </h:inputText>
            </s:decorate>

            <div style="clear:both">
                <span class="required">*</span>
                Campos Requeridos 
            </div>
        <div class="actionButtons">

            <h:commandButton id="save"
                          value="Guardar"
                         action="#{invIngresoHome.persist}"
                       disabled="#{!invIngresoHome.wired}"
                       rendered="#{!invIngresoHome.managed}"/>
            <s:button id="cancelAdd"
                   value="Cancel"
             propagation="end"
                    view="/#{empty invIngresoFrom ? 'InvIngresoList' : invIngresoFrom}.xhtml"
                rendered="#{!invIngresoHome.managed}"/>

        </div>

        </rich:panel>

        <h:panelGrid columns="2" style="TEXT-DECORATION: underline;">

                                        <h:commandButton value="Agregar Items" action="#{ingresoListado.agregarItems}" >
                                     
                                        </h:commandButton>
                                        <h:commandButton value="Eliminar Items"
                                                action="#{ingresoListado.BorraSeleccionado}" />
                                        
                               </h:panelGrid>
           <rich:dataTable value="#{ingresoItems}" var="rowing">
                        <rich:column>
                                <f:facet name="header">
                                        <h:outputText value="Seleccionar" />
                                </f:facet>
                                <h:selectBooleanCheckbox value="#{rowing.seleccionarManual}" />
                        </rich:column>
                        <rich:column>
	                                <f:facet name="header">
	                                        <h:outputText value="Grupo" />
	                                </f:facet>
	             <h:selectOneMenu value="#{rowing.gruCodigo}">
	 				
	<f:selectItems value="#{grupoListado.grupoSelectItems}"  />
	 <a:support event="onchange" reRender="Comboitems" ajaxSingle="true" />
	</h:selectOneMenu>
                   </rich:column>
                   
                   
                   
                   <rich:column>
                                <f:facet name="header">
                                        <h:outputText value="Items" />
                                        
                                </f:facet>
                              <h:selectOneMenu id="Comboitems" value ="#{rowing.auxInvItem}" >
					<f:selectItems value="#{grupoListado.listaItemsSelectItems}"  />
					</h:selectOneMenu>
                   </rich:column>
                         <rich:column>
                                <f:facet name="header">
                                        <h:outputText value="Cantidad" size="3" />
                                </f:facet>  
                                <h:inputText id="iniCantidad" value="#{rowing.iniCantidad}" required="true" requiredMessage="Ingrese la cantidad" maxlength="5" >
                                	<a:support  event="onchange" reRender="cantidadxCostoU"  ajaxSingle="true" />
                                 </h:inputText>                         
                        		</rich:column>
                        <rich:column>
                                <f:facet name="header">
                                        <h:outputText value="Costo Unitario" />
                                </f:facet>
                                
                                <h:inputText value="#{rowing.iniCostoU}" required="true" >
                                <a:support  event="onchange" reRender="cantidadxCostoU,total,total1, Iva1,Descuento1"  ajaxSingle="false" />
                                </h:inputText>
                        </rich:column>
       					 <rich:column>
                                <f:facet name="header">
                                        <h:outputText value="Costo Total" />
                                </f:facet>
                                <h:outputText id="cantidadxCostoU"  value="${rowing.iniCostoU*rowing.iniCantidad}">
                                    
                                    <a:support event="onchange" reRender="iniCostoTotal" ajaxSingle="true" />
                                 </h:outputText>
                        </rich:column>
                </rich:dataTable>
                
<h:panelGrid columns="2" style="TEXT-DECORATION: underline;">
        <h:column>
        <s:decorate id="Total1" template="layout/edit.xhtml">
                <ui:define name="label">Total Neto:</ui:define>
                <h:outputText  id="total" 
                 value="#{listadoDeOperacion.varTotalDeIngreso}">
                </h:outputText>
            </s:decorate>
            
            <s:decorate id="Iva" template="layout/edit.xhtml">
                <ui:define name="label">Iva:</ui:define>
                <h:outputText  id="Iva1" 
                 value="#{listadoDeOperacion.varTotalDeIVA}">
                </h:outputText>
            </s:decorate>
            <s:decorate id="Descuento" template="layout/edit.xhtml">
                <ui:define name="label">Descuento:</ui:define>
                <h:outputText  id="Descuento1" 
                 value="#{listadoDeOperacion.varTotalDeDescuento}">
                </h:outputText>
            </s:decorate>
            <s:decorate id="Total2" template="layout/edit.xhtml">
                <ui:define name="label">Total:</ui:define>
                <h:outputText  id="total1" 
                 value="#{listadoDeOperacion.varTotal}">
                </h:outputText>
            </s:decorate>
        </h:column>
        </h:panelGrid>        
                    
                
    </h:form>

<rich:tabPanel switchType="ajax" style=" height : 11px;">
</rich:tabPanel>
</ui:define>

</ui:composition>
